﻿<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="../../../assets/docs.css" rel="stylesheet" type="text/css" media="screen" />
<title>MooTools Documentation - Interface/Keyboard.Extras</title>
</head>

<body>
  <div class="doc">
    <div class="methods">
			<h4 class="menu-item"><a href="#Keyboard">Keyboard</a></h4>
			<div class="menu-item"><a href="#Keyboard:addShortcut">addShortcut</a></div>
			<div class="menu-item"><a href="#Keyboard:addShortcuts">addShortcuts</a></div>
			<div class="menu-item"><a href="#Keyboard:getShortcuts">getShortcuts</a></div>
			<div class="menu-item"><a href="#Keyboard:getShortcut">getShortcut</a></div>
			<div class="menu-item"><a href="#Keyboard:rebind">rebind</a></div>
			<div class="menu-item"><a href="#Keyboard:getActiveShortcuts">getActiveShortcuts</a></div>
			<div class="menu-item"><a href="#Keyboard:Keyboard.getShortcut">Keyboard.getShortcut</a></div>
			<div class="menu-item"><a href="#Keyboard:Keyboard.getShortcuts">Keyboard.getShortcuts</a></div>
    </div>
    <div class="l-border r-border span-15 content">
				<h1 id="Keyboard"><a href="#Keyboard">Class: Keyboard</a></h1>

<p class="description">Adds some methods for creating shortcuts to the <a href="Keyboard.html">Keyboard</a> Class.</p>

<h2 id="Keyboard:addShortcut"><a href="#Keyboard:addShortcut">Keyboard Method: addShortcut</a></h2>

<p class="description">Associates a event handler with a name and description.</p>

<h3>Syntax</h3>

<pre class="javascript">myKeyboard.<span class="me1">addShortcut</span><span class="br0">(</span><span class="st0">'save'</span>, <span class="br0">{</span>
    <span class="st0">'keys'</span>: <span class="st0">'ctrl+s'</span>,
    <span class="st0">'description'</span>: <span class="st0">'Save the current document'</span>,
    <span class="st0">'handler'</span>: doSaveFunc
<span class="br0">}</span><span class="br0">)</span>;
</pre>

<h3>Arguments</h3>

<ol>
<li>name - (<em>string</em>) The name of the shortcut.</li>
<li>shortcut - (<em>object</em>)

<ul>
<li>keys - (<em>string (optional)</em>) Same as the argument that you would pass to addEvent. If not passed it will not automatically add it as an event on the Keyboard.</li>
<li>description - (<em>string</em>) A brief description of the functionality.</li>
<li>handler - (<em>function</em>) The event handler function.</li>
</ul>
</li>
</ol>
<h3>Returns</h3>

<ul>
<li>(<em>object</em>) A new instance of <a href="Keyboard.html">Keyboard</a>
</li>
</ul>
<h2 id="Keyboard:addShortcuts"><a href="#Keyboard:addShortcuts">Keyboard Method: addShortcuts</a></h2>

<p class="description">Same as addShortcut but can send many as key, value pairs.</p>

<h3>Syntax</h3>

<pre class="javascript">myKeyboard.<span class="me1">addShortcut</span><span class="br0">(</span><span class="br0">{</span>
    <span class="st0">'save'</span>, <span class="br0">{</span>
        <span class="st0">'keys'</span>: <span class="st0">'ctrl+s'</span>,
        <span class="st0">'description'</span>: <span class="st0">'Save the current document'</span>,
        <span class="st0">'handler'</span>: doSaveFunc
    <span class="br0">}</span>,
    <span class="st0">'open'</span>, <span class="br0">{</span>
        <span class="st0">'keys'</span>: <span class="st0">'ctrl+o'</span>,
        <span class="st0">'description'</span>: <span class="st0">'Open a document'</span>,
        <span class="st0">'handler'</span>: doOpenFunc
    <span class="br0">}</span>
<span class="br0">}</span><span class="br0">)</span>;
</pre>

<h3>Arguments</h3>

<ul>
<li>obj - (<em>object</em>) An object of key value pairs to be sent to addShortcut.</li>
</ul>
<h3>Returns</h3>

<ul>
<li>(<em>object</em>) A new instance of <a href="Keyboard.html">Keyboard</a>
</li>
</ul>
<h2 id="Keyboard:getShortcuts"><a href="#Keyboard:getShortcuts">Keyboard Method: getShortcuts</a></h2>

<p class="description">Gets all shortcuts on the Keyboard instance.</p>

<h3>Syntax</h3>

<pre class="javascript">myKeyboard.<span class="me1">getShortcuts</span><span class="br0">(</span><span class="br0">)</span>;
</pre>

<h3>Returns</h3>

<ul>
<li>(<em>array</em>) An array of shortcuts on the Keyboard.</li>
</ul>
<h2 id="Keyboard:getShortcut"><a href="#Keyboard:getShortcut">Keyboard Method: getShortcut</a></h2>

<p class="description">Get a shortcut with the name passed in.</p>

<h3>Syntax</h3>

<pre class="javascript">myKeyboard.<span class="me1">getShortcut</span><span class="br0">(</span><span class="st0">'save'</span><span class="br0">)</span>;
</pre>

<h3>Arguments</h3>

<ul>
<li>name - (<em>string</em>) The name of the shortcut to lookup.</li>
</ul>
<h3>Returns</h3>

<ul>
<li>(<em>object</em> or <em>null</em>) The shortcut with the name if found.</li>
</ul>
<h2 id="Keyboard:rebind"><a href="#Keyboard:rebind">Static Method: Keyboard.rebind</a></h2>

<p class="description">Unbinds the shortcuts passed in and rebinds them to the keys that are passed in.</p>

<h3>Syntax</h3>

<pre class="javascript">myKeyboard.<span class="me1">rebind</span><span class="br0">(</span><span class="st0">'shift+s'</span>, shortcutObjs<span class="br0">)</span>;
</pre>

<h3>Arguments</h3>

<ul>
<li>keys - (<em>string</em>) The new shortcut for the shortcuts.</li>
<li>shortcuts - (<em>object</em> or <em>array[object]</em>) One or more shortcuts to rebind.</li>
</ul>
<h2 id="Keyboard:getActiveShortcuts"><a href="#Keyboard:getActiveShortcuts">Static Method: Keyboard.getActiveShortcuts</a></h2>

<p class="description">Gets all active shortcuts using the passed in Keyboard or Keyboard.manager as a starting point.</p>

<h3>Syntax</h3>

<pre class="javascript">myKeyboard.<span class="me1">getActiveShortcuts</span><span class="br0">(</span><span class="br0">)</span>;
</pre>

<h3>Arguments</h3>

<ul>
<li>keyboard - (<em>object</em>: optional) The Keyboard object used to start looking. Keyboard.manager by default.</li>
</ul>
<h3>Returns</h3>

<ul>
<li>(<em>array</em>) An array containing all of the active shortcuts.</li>
</ul>
<h2 id="Keyboard:Keyboard.getShortcut"><a href="#Keyboard:Keyboard.getShortcut">Static Method: Keyboard.getShortcut</a></h2>

<p class="description">Goes through all active keyboards using the passed in keyboard or Keyboard.manager as a starting point and attempts to find a shortcut with the name passed in.</p>

<h3>Syntax</h3>

<pre class="javascript">Keyboard.<span class="me1">getShortcut</span><span class="br0">(</span><span class="st0">'save'</span><span class="br0">)</span>;
</pre>

<h3>Arguments</h3>

<ul>
<li>name - (<em>string</em>) The name of the shortcut to lookup.</li>
<li>keyboard - (<em>object (optional)</em>) The keyboard to start looking on.</li>
</ul>
<h3>Returns</h3>

<ul>
<li>(<em>object</em> or <em>null</em>) The shortcut with the name if found.</li>
</ul>
<h2 id="Keyboard:Keyboard.getShortcuts"><a href="#Keyboard:Keyboard.getShortcuts">Static Method: Keyboard.getShortcuts</a></h2>

<p class="description">Same as Keyboard.getShortcut but gets all that match the name.</p>

<h3>Syntax</h3>

<pre class="javascript">myKeyboard.<span class="me1">getShortcuts</span><span class="br0">(</span><span class="st0">'save'</span><span class="br0">)</span>;
</pre>

<h3>Arguments</h3>

<ul>
<li>name - (<em>string</em>) The name of the shortcut to lookup.</li>
<li>keyboard - (<em>object (optional)</em>) The keyboard to start looking on.</li>
</ul>
<h3>Returns</h3>

<ul>
<li>(<em>array</em>) An array of shortcuts with the name passed in.</li>
</ul>
    </div>
  </div>
<script type="text/javascript" src="../../../assets/mootools-core-1.3.js"></script>
<script type="text/javascript" src="../../../assets/mootools-more-smoothscroll.js"></script>
<script type="text/javascript" src="../../../assets/doc-assist.js"></script>
</body>
</html>
